package com.jy.adscm.operation.hr.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.jy.adscm.bean.system.JyUser;
import com.jy.adscm.operation.hr.bean.HrResume;
import com.jy.adscm.operation.hr.mapper.mysql.HrResumeMapper;
import com.jy.adscm.operation.hr.service.HrResumeService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.jy.adscm.system.mapper.mysql.JyUserMapper;
import com.jy.adscm.utils.AdscmBaseUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 人力资源简历 服务实现类
 * </p>
 *
 * @author zyl
 * @since 2020-01-07
 */
@Service
public class HrResumeServiceImpl extends ServiceImpl<HrResumeMapper, HrResume> implements HrResumeService {
    @Autowired
    JyUserMapper jyUserMapper;
    @Override
    public boolean insertHrResume(HrResume hrResume) {
        boolean insert = super.insert(hrResume);
        return insert;
    }

    @Override
    public boolean updateHrResume(HrResume hrResume) {

        boolean b = super.updateById(hrResume);
        return b;
    }

    @Override
    public List<HrResume> selectByHid(Integer hid) {
        Wrapper<HrResume> hrResumeWrapper=new EntityWrapper<>();
        hrResumeWrapper.eq("hid",hid);
        List<HrResume> hrResumes = super.selectList(hrResumeWrapper);
        for (HrResume hrResume : hrResumes) {
            if (AdscmBaseUtils.getInstance().isNotEmpty(hrResume.getCreator(),null)){
                JyUser jyUser = jyUserMapper.selectById(hrResume.getCreator());
                hrResume.setCreatorName(jyUser.getName());
            }
        }
        return hrResumes;
    }
}
